GetValue - JSONArray

Note: This statement is not available in the Add Statement dialog box or the Statements pane.

Returns the value of an index in a JSONArray or a default value if the index is out of range.

Syntax

GetValue(Index, DefaultReturnValue)

Arguments

Argument Description
Index Index in the JSONArray. Indexes are zero based.
DefaultReturnValue Value to return if the index is out of range. If not specified, the default value is null.

Supported objects

JSONArray

Return value

Value Description
Value Value of the index in JSONArray. The DefaultReturnValue is returned if the index is out of range.

Example

jsonArray = JSONNewArray()

' Appends 1 and 2 to end of array

jsonArray.Push(1)

jsonArray.Push(2)

' Sets first index in array to -1

jsonArray.SetValue(0, -1)

' Returns -1

intVal = jsonArray.GetValue(0)

PrintLn("Should be -1: " & intVal)